<template>
  <div>
      <el-button type="primary" @click="willAdd">添加</el-button>
      
      <v-list @willEdit="willEdit" :list="list" @init="init"></v-list>
     
      <v-form :info="info" :list="list" @init="init" ref="form"></v-form>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import vForm from "./components/form.vue";
import vList from "./components/list.vue";
import { reqmenulist } from "../../https/api";
import {toggle}  from "../../mixins/toggle"
export default {
  mixins:[toggle],
  components: {
    vList,
    vForm,
  },
  props: [],
  data() {
    return {
        // 初始化列表数据
        list:[]
    };
  },
  computed: {
    ...mapGetters({}),
  },
  methods: {
    ...mapActions({}),
    // 刷新列表
    init(){
        reqmenulist( {istree:true} ).then( (res)=>{
          // console.log(res);
            if(res.data.code == 200){
                this.list = res.data.list;
            }
        })
    },
  },
  mounted() {
  //   一进页面就获取数据
     this.init();
  },
};
</script>
<style lang="less" scoped>
@import "../../less/index.less";
</style>